<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/11/6
 * Time: 15:47
 */

namespace app\index\validate;


use think\Validate;

class Coupon extends Validate
{

    protected $rule = [
                            'title'         => 'require',
                            'type'          => 'require|number',
                            'start_date'   => 'require',
                            'expire_date'  => 'require',
                            'get_start_time'=> 'require',
                            'get_end_time'  => 'require',
                            'fileInfo'      =>'require|imageCollection:',//图像集合
                        ];
    protected $message=[
                        'title.require'         =>'请填写优惠卷的名称',
                        'type.require'          =>'请选择优惠卷的类型',
                        'start_date.require'    =>'请选择优惠卷的开始时间',
                        'expire_date.require'   =>'请选择优惠卷
                        的结束时间',
                        'get_start_time.require'=>'请选择优惠卷的领取开始时间',
                        'get_end_time.require'  =>'请选择优惠卷的领取结束时间',
                        'number.require'        =>'请选择优惠卷的领取数量',
                         'fileInfo.require'     =>"优惠卷图像集合不能为空",
    ];
    protected function imageCollection($value){
        if(empty($value['picture_used']))return '已使用过的优惠卷图片没有上传';
        if(empty($value['picture_invalid']))return '已过期的优惠卷图片没有上传';
        if(empty($value['picture_use']))return '待使用过的优惠卷图片没有上传';
        return true;
    }



}






















